package com.hellpro.lolbox.video.view.fragment.view;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.widget.ListView;

import com.hellpro.lolbox.R;
import com.hellpro.lolbox.base.BaseFragment;
import com.hellpro.lolbox.config.UrlConfigs;
import com.hellpro.lolbox.video.bean.VideoClassifyBean;
import com.hellpro.lolbox.video.presenter.VideoPresenter;
import com.hellpro.lolbox.video.view.fragment.IClassifyFragment;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;

import butterknife.BindView;

/**
 * 类描述:
 * 创建人:阿犇
 * 创建时间:2016/10/19
 * 备注:视频页面分类模块
 */
public class ClassifyFragment extends BaseFragment implements IClassifyFragment {


    @BindView(R.id.video_classify_lv)
    ListView mLv;
    private VideoPresenter presenter;


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getHomeEventBean(List<VideoClassifyBean> data) {
        presenter.setClassifyAdapter(data,mLv,getActivity());
    }
    @Override
    public void initView() {

        presenter = new VideoPresenter(this, getActivity());
        presenter.setClassifyInfo();
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_classify;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //Eventbus绑定
        if (!EventBus.getDefault().isRegistered(this)){
            EventBus.getDefault().register(this);
        }
    }

    /**
     *
     * 类描述:
     * 创建人:阿犇
     * 创建时间:2016/10/19
     * 备注:获取分类导航的RecyclerView
     */
    @Override
    public ListView getListView() {
        return mLv;
    }


    /**
     *
     * 类描述:
     * 创建人:阿犇
     * 创建时间:2016/10/19
     * 备注:获取分类导航的数据的网址
     */
    @Override
    public String getClassifyUrl() {
        return UrlConfigs.VIDEO_CLASSIFY_PATH;
    }

    /**
     *
     * 类描述:
     * 创建人:阿犇
     * 创建时间:2016/10/19
     * 备注:获取分类导航的下拉刷新控件
//     */
//    @Override
//    public SwipeRefreshLayout getSwipeRefreshLayout() {
//        return videoClassifyRefresh;
//    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(getActivity());
    }
}
